*Script file for observational data analyses
*for "The Journey Home: Violence, Anchoring, and Refugee Decisions to Return"
*Ghosn, Chu, Simon, Braithwaite, Frith, and Jandala


cd "/Users/tiffanychu/Dropbox/Collaborations/RefugeesConflict//Outputs/RiskPerceptionReturn/APSR Submission/Survey Data Acceptance Submission/"

use "Journey Home Data.dta", clear



*** H1: Traditional Hyp: Violence, Model 1 
ologit never_return_ord i.exp_viol_bin  ///
disp_dur_yr i.htwn_governate i.education i.income  age married male children  
estimates store m1

*** H2: Homeland attachment, Model 2
ologit never_return_ord i.exp_viol_bin  i.htwn_prop_left  i.syrnbhd lbn_easybordercrossing employment2011 i.discussfleeing  ///
disp_dur_yr i.htwn_governate i.education i.income  age married male children  
estimates store m2

*** H3: Host/Social attachment, Model 3
ologit never_return_ord  i.closefam_lbn  employed  sitlbn_worse un_regis living_camp i.rpt_police i.hh_large ///
disp_dur_yr i.htwn_governate i.education i.income  age married male children  
estimates store m3

* All, Model 4
ologit never_return_ord i.exp_viol_bin disp_dur_yr i.htwn_prop_left  i.syrnbhd lbn_easybordercrossing employment2011 i.discussfleeing i.closefam_lbn  employed  sitlbn_worse un_regis living_camp i.rpt_police i.hh_large /// 
i.htwn_governate i.education i.income  age married male children  
estimates store m4

* Table 2 in manuscript, Models 1-4 above
estout m1 m2 m3 m4, style(tex) cells(b(star fmt(%9.3f)) se(par)) stats (N, fmt(%9.8g)) starlevels(# 0.10 * 0.05 ** 0.01 *** 0.001) drop(*.htwn_governate 0.*)


*Following "tab" command to put together Table 3 in Appendix D
tab never_return_ord exp_viol_bin
tab never_return_ord htwn_prop_left
tab never_return_ord syrnbhd
tab never_return_ord lbn_easybordercrossing
tab never_return_ord employment2011
tab never_return_ord discussfleeing
tab never_return_ord closefam_lbn
tab never_return_ord employed
tab never_return_ord sitlbn_worse
tab never_return_ord un_regis
tab never_return_ord living_camp
tab never_return_ord rpt_police
tab never_return_ord hh_large


*Rerunning model 4 for graphics
ologit never_return_ord i.exp_viol_bin disp_dur_yr i.ht_1 i.ht_2  i.syrnbhd i.lbn_easybordercrossing employment2011 i.discussfleeing i.closefam_lbn  employed  i.sitlbn_worse un_regis living_camp i.rpt_police i.hh_large /// 
i.htwn_governate i.education i.income  age married male children, or  


*Panel 1 in Figure 1 in the manuscript
margins, dydx(exp_viol_bin)
marginsplot, recast(scatter) yline(0) ytitle("Change in Probability (AME)") ///
xtitle("") ///
title("Experienced Violence") ///
xlabel(1 " " 2 "Agree" 3 " " 4 "Neutral" 5 " " 6 "Disagree" 7 " ")
*graph save Graph "/Users/tiffanychu/Dropbox/Collaborations/RefugeesConflict/Outputs/RiskPerceptionReturn/Drafts/Graphs/AME_OL_ExpViol.gph", replace

*Panel 2 in Figure 1 in the manuscript
margins, dydx(discussfleeing)
marginsplot, recast(scatter) yline(0) ytitle("Change in Probability (AME)") ///
xtitle("") ///
title("Discussed Fleeing") ///
xlabel(1 " " 2 "Agree" 3 " " 4 "Neutral" 5 " " 6 "Disagree" 7 " ")
*graph save Graph "/Users/tiffanychu/Dropbox/Collaborations/RefugeesConflict/Outputs/RiskPerceptionReturn/Drafts/Graphs/AME_OL_DissFlee.gph", replace

*Panel 3 in Figure 1 in the manuscript
margins, dydx(ht_1)
marginsplot, recast(scatter) yline(0) ytitle("Change in Probability (AME)") ///
xtitle("") ///
title("Half of Hometown Fled") ///
xlabel(1 " " 2 "Agree" 3 " " 4 "Neutral" 5 " " 6 "Disagree" 7 " ")
*graph save Graph "/Users/tiffanychu/Dropbox/Collaborations/RefugeesConflict/Outputs/RiskPerceptionReturn/Drafts/Graphs/AME_OL_HtwnFled1.gph", replace

*Panel 4 in Figure 1 in the manuscript
margins, dydx(ht_2)
marginsplot, recast(scatter) yline(0) ytitle("Change in Probability (AME)") ///
xtitle("") ///
title("Most of Hometown Fled") ///
xlabel(1 " " 2 "Agree" 3 " " 4 "Neutral" 5 " " 6 "Disagree" 7 " ")
*graph save Graph "/Users/tiffanychu/Dropbox/Collaborations/RefugeesConflict/Outputs/RiskPerceptionReturn/Drafts/Graphs/AME_OL_HtwnFled2.gph", replace

*Panel 1 in Figure 2 in the manuscript
margins, dydx(lbn_easybordercrossing)
marginsplot, recast(scatter) yline(0) ytitle("Change in Probability (AME)") ///
xtitle("") ///
title("Easy Border Crossing") ///
xlabel(1 " " 2 "Agree" 3 " " 4 "Neutral" 5 " " 6 "Disagree" 7 " ")
*graph save Graph "/Users/tiffanychu/Dropbox/Collaborations/RefugeesConflict/Outputs/RiskPerceptionReturn/Drafts/Graphs/AME_OL_BorderCross.gph", replace

*Panel 2 in Figure 2 in the manuscript
margins, dydx(syrnbhd)
marginsplot, recast(scatter) yline(0) ytitle("Change in Probability (AME)") ///
xtitle("") ///
title("Reside in Syrian Neighborhood") ///
xlabel(1 " " 2 "Agree" 3 " " 4 "Neutral" 5 " " 6 "Disagree" 7 " ")
*graph save Graph "/Users/tiffanychu/Dropbox/Collaborations/RefugeesConflict/Outputs/RiskPerceptionReturn/Drafts/Graphs/AME_OL_SyrNbhd.gph", replace

*Panel 3 in Figure 2 in the manuscript
margins, dydx(sitlbn_worse)
marginsplot, recast(scatter) yline(0) ytitle("Change in Probability (AME)") ///
xtitle("") ///
title("Worsening Situation") ///
xlabel(1 " " 2 "Agree" 3 " " 4 "Neutral" 5 " " 6 "Disagree" 7 " ")
*graph save Graph "/Users/tiffanychu/Dropbox/Collaborations/RefugeesConflict/Outputs/RiskPerceptionReturn/Drafts/Graphs/AME_OL_Worse.gph", replace



cd "/Users/tiffanychu/Dropbox/Collaborations/RefugeesConflict/Outputs/RiskPerceptionReturn/Drafts/Graphs/"

*Combining panels of graphs to create Figure 1 in manuscript
graph combine "AME_OL_ExpViol.gph"  "AME_OL_DissFlee" "AME_OL_HtwnFled1.gph" "AME_OL_HtwnFled2.gph" ,  ycommon commonscheme rows(1) xsize(8)

*Combining panels of graphs to create Figure 2 in manuscript
graph combine "AME_OL_BorderCross.gph"  "AME_OL_SyrNbhd" "AME_OL_Worse.gph" ,  ycommon commonscheme rows(1) xsize(8)

*********************
* Appendix models
*********************

*Used to put the Correlation matrix together, Table 2 in Appendix D
ologit never_return_ord i.exp_viol_bin disp_dur_yr i.htwn_prop_left  i.syrnbhd lbn_easybordercrossing employment2011 i.discussfleeing i.closefam_lbn  employed  sitlbn_worse un_regis living_camp i.rpt_police i.hh_large /// 
i.htwn_governate i.education i.income  age married male children  
estpost correlate  never_return_ord exp_viol_bin disp_dur_yr htwn_prop_left  syrnbhd lbn_easybordercrossing employment2011 discussfleeing ///
 closefam_lbn  employed  sitlbn_worse un_regis living_camp rpt_police hh_large /// 
education income  age married male children  if e(sample)==1, matrix listwise
eststo correlation
esttab correlation using corrmatrix.rtf, unstack not noobs compress b(2)

*Never return 5 categories ordered logit, Model 1 in Table 1 of Appendix E
ologit never_return_ord5 i.exp_viol_bin disp_dur_yr i.htwn_prop_left  i.syrnbhd lbn_easybordercrossing employment2011 i.discussfleeing i.closefam_lbn  employed  sitlbn_worse un_regis living_camp i.rpt_police i.hh_large /// 
i.htwn_governate i.education i.income  age married male children  
*outreg2 using "RegTablesWord/AppendixModels.doc", drop(i.htwn_governate) e(N ll chi2) replace title("Alternative Variable Specifications") alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, +)

*Never return 3 categories ordered logit, Model 2 in Table 1 of Appendix E
ologit never_return_ord3 i.exp_viol_bin disp_dur_yr i.htwn_prop_left  i.syrnbhd lbn_easybordercrossing employment2011 i.discussfleeing i.closefam_lbn  employed  sitlbn_worse un_regis living_camp i.rpt_police i.hh_large /// 
i.htwn_governate i.education i.income  age married male children  
*outreg2 using "RegTablesWord/AppendixModels.doc", drop(i.htwn_governate) e(N ll chi2)  title("Alternative Variable Specifications") alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, +)


*Adding variable on whether family was exposed to violence, Model 3 in Table 1 of Appendix E
ologit never_return_ord i.exp_viol_bin i.exp_viol_bin_f disp_dur_yr i.htwn_prop_left  i.syrnbhd lbn_easybordercrossing employment2011 i.discussfleeing i.closefam_lbn  employed  sitlbn_worse un_regis living_camp i.rpt_police i.hh_large /// 
i.htwn_governate i.education i.income  age married male children  
*outreg2 using "RegTablesWord/AppendixModels.doc", drop(i.htwn_governate) e(N ll chi2)  title("Alternative Variable Specifications") alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, +)

*Additive index of viol experiences
ologit never_return_ord exp_viol_count disp_dur_yr i.htwn_prop_left  i.syrnbhd lbn_easybordercrossing employment2011 i.discussfleeing i.closefam_lbn  employed  sitlbn_worse un_regis living_camp i.rpt_police i.hh_large /// 
i.htwn_governate i.education i.income  age married male children  
*outreg2 using "RegTablesWord/AppendixModels.doc", drop(i.htwn_governate) e(N ll chi2)  title("Alternative Variable Specifications") alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, +)



*Conditional effect of gender and violence, Table F.3 in Appendix
 ologit never_return_ord i.exp_viol_bin##i.male disp_dur_yr i.htwn_prop_left  i.syrnbhd lbn_easybordercrossing employment2011 i.discussfleeing i.closefam_lbn  employed  sitlbn_worse un_regis living_camp i.rpt_police i.hh_large /// 
i.htwn_governate i.education i.income  age married  children  
*outreg2 using "RegTablesWord/GenderInteraction.doc", drop(i.htwn_governate) e(N ll chi2)  replace title("Interacting Gender with Violence Experience") alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, +)

 
*Cronbach's alpha, Results in Appendix D
ologit never_return_ord5 i.exp_viol_bin disp_dur_yr i.htwn_prop_left  i.syrnbhd lbn_easybordercrossing employment2011 i.discussfleeing i.closefam_lbn  employed  sitlbn_worse un_regis living_camp i.rpt_police i.hh_large /// 
i.htwn_governate i.education i.income  age married male children  
alpha exp_assault exp_torture exp_abduction exp_sv exp_flabor exp_wagetheft exp_shotat exp_shelling exp_other if e(sample)==1

*Results withLebanese Governate fixed effects, Table 1 in Appendix H
*Model 1 in Table 1 in Appendix H
ologit never_return_ord i.exp_viol_bin  ///
disp_dur_yr i.htwn_governate i.education i.income  age married male children  
*outreg2 using "RegTablesWord/GovFE.doc", e(N ll chi2) replace title("Models with Governate FEs") alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, +)
*Model 2 in Table 1 in Appendix H
ologit never_return_ord i.exp_viol_bin  i.htwn_prop_left  i.syrnbhd lbn_easybordercrossing employment2011 i.discussfleeing  ///
disp_dur_yr i.htwn_governate i.education i.income  age married male children  
*outreg2 using "RegTablesWord/GovFE.doc", e(N ll chi2)  title("Models with Governate FEs") alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, +)
*Model 3 in Table 1 in Appendix H
ologit never_return_ord  i.closefam_lbn  employed  sitlbn_worse un_regis living_camp i.rpt_police i.hh_large ///
disp_dur_yr i.htwn_governate i.education i.income  age married male children  
*outreg2 using "RegTablesWord/GovFE.doc", e(N ll chi2)  title("Models with Governate FEs") alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, +)
*Model 4 in Table 1 in Appendix H
ologit never_return_ord i.exp_viol_bin disp_dur_yr i.htwn_prop_left  i.syrnbhd lbn_easybordercrossing employment2011 i.discussfleeing i.closefam_lbn  employed  sitlbn_worse un_regis living_camp i.rpt_police i.hh_large /// 
i.htwn_governate i.education i.income  age married male children  
*outreg2 using "RegTablesWord/GovFE.doc", e(N ll chi2)  title("Models with Governate FEs") alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, +)



*Used to put together Table 1 in Appendix D
asdoc sum never_return_ord exp_viol_bin disp_dur_yr htwn_prop_left  syrnbhd lbn_easybordercrossing employment2011 discussfleeing closefam_lbn  employed  sitlbn_worse un_regis living_camp rpt_police hh_large /// 
 education income  age married male children if e(sample)==1, save(RegTablesWord/summarystats.doc)
